﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using BusinessLogicLayer;
using DataAccessComponents;

namespace inzDesktop
{
    /// <summary>
    /// Interaction logic for windowZmienHotel.xaml
    /// </summary>
    public partial class windowZmienHotel : Window
    {
        public windowZmienHotel()
        {
            InitializeComponent();

            // Inicjalizacja listy krajów
            KrajBL krajBL = new KrajBL();
            cbKraj.ItemsSource = krajBL.pobierzListe();
            
        }

        private int id_hotelu;

        public int Id_hotelu
        {
            get { return id_hotelu; }
            set { id_hotelu = value; }
        }

        private Hotel hotel;

        public Hotel Hotel
        {
            get { return hotel; }
            set { hotel = value; }
        }

        private void cbKraj_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (cbKraj.SelectedItem != null)
            {
                MiastoBL miastoBL = new MiastoBL();
                Kraj kraj = cbKraj.SelectedItem as Kraj;
                cbMiasto.ItemsSource = miastoBL.pobierzListe(kraj.Id_kraju);
                cbMiasto.IsEnabled = true;
            }
        }

        private void cbMiasto_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (cbMiasto.SelectedItem != null)
            {
                HotelBL hotelBL = new HotelBL();
                Miasto miasto = cbMiasto.SelectedItem as Miasto;
                cbHotel.ItemsSource = hotelBL.pobierzListe(miasto.Id_miasta);
                cbHotel.IsEnabled = true;
            }
        }

        private void cbHotel_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            btnOK.IsEnabled = true;
        }

        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            id_hotelu = (cbHotel.SelectedItem as Hotel).Id_hotelu;
            hotel = cbHotel.SelectedItem as Hotel;
            DialogResult = true;
        }

        private void btnAnuluj_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
        }
    }
}
